package com.lzkj.baotouhousingfund.http;


import com.lzkj.baotouhousingfund.http.api.ApiInterface;

import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;

/**
 *
 * @ClassName: RetrofitHelper
 * @Description: 网络请求类
 * @author Chengs
 * @date 2018/3/8 16:51
 *
 */
public class RetrofitHelper {

    private ApiInterface mApiInterface;

    public RetrofitHelper(ApiInterface apiInterface) {
        mApiInterface = apiInterface;
    }


    /**
     * 倒计时
     *
     * @param time
     * @return
     */
    public Observable<Integer> countdown(int time) {
        if (time < 0) {
            time = 0;
        }
        final int countTime = time;

        return Observable.interval(0, 1, TimeUnit.SECONDS)
                .map(aLong -> countTime - aLong.intValue())
                .take(countTime + 1);

    }

}
